function immediately() {
    var oldPassword = document.getElementById("oldPassword");
    var newPassword = document.getElementById('newPassword');
    var rePassword = document.getElementById('rePassword');

    if ("\v" == "v") {
        oldPassword.onpropertychange = checkPasswords;
        newPassword.onpropertychange = checkPasswords;
        rePassword.onpropertychange = checkPasswords;
    } else {
        oldPassword.addEventListener("input", checkPasswords, false);
        newPassword.addEventListener("input", checkPasswords, false);
        rePassword.addEventListener("input", checkPasswords, false);
    }
    function checkPasswords() {
        if(oldPassword.value != "" && oldPassword.value.length >= 6){
            if (newPassword.value == "" && rePassword.value != ""){
                newPassword.setCustomValidity('请填入新密码。');
            }

            else{
                newPassword.setCustomValidity('');
            }

            if (rePassword.value != newPassword.value){
                rePassword.setCustomValidity('确认密码失败，请重新输入。');
            }

            else{
                rePassword.setCustomValidity('');
            }

        }
        else if(oldPassword.value == "" && (newPassword.value != "" || rePassword.value != "")) {
            oldPassword.setCustomValidity('请填入旧密码。');
        }
        else{
                oldPassword.setCustomValidity('');
        }
    }
}

function checkCardID() {
    var cardname = document.getElementById('cardname');
    var cardid = document.getElementById('cardid');
    if (cardname.value =="身份证") {
        if(!cardid.value.match(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/)){
            cardid.setCustomValidity('请输入正确的身份证号。');
        }
        else
            cardid.setCustomValidity("");
    }
    else {
        if(!cardid.value.match(/(^\d{8}$)/)){
            cardid.setCustomValidity('请输入正确的学生证号。');
        }
        else
            cardid.setCustomValidity("");
    }
}

function confirmPassword() {
    var password = document.getElementById('password');
    var rePassword = document.getElementById('rePassword');
    if (password.value == "" && password.value != "") {
        password.setCustomValidity('请填入密码。');
    }

    else {
        password.setCustomValidity('');
    }

    if (rePassword.value != password.value) {
        rePassword.setCustomValidity('确认密码失败，请重新输入。');
    }

    else {
        rePassword.setCustomValidity('');
    }
}